<template>
  <e-table
    @getList="handleGetList"
    :tableData="tableData"
    :columns="columns"
    :loading="loading"
    :total="total"
  >
    <el-table-column slot="name" :label="mdl.planType === 1 ? '区域名称' : '部门名称'" align="center">
      <span slot-scope="scope">{{ mdl.planType === 1 ? scope.row.areaName : scope.row.deptName }}</span>
    </el-table-column>
    <el-table-column slot="schedule" label="当前进度" align="center">
      <span slot-scope="scope">
        <el-progress
          :text-inside="true"
          color="#52c41a"
          :stroke-width="20"
          :percentage="scope.row.schedule ? Math.floor(scope.row.schedule) : 0"
        />
      </span>
    </el-table-column>
  </e-table>
</template>

<script>
// import { queryCheckDetails } from '@/api/assets'
import { planDetails } from '@/api/assetsNew'
import { openNotification } from '@/utils/util'

export default {
  data() {
    return {
      loading: false,
      // 表头
      columns: [
        { slot: 'name' },
        {
          label: '盘点负责人',
          prop: 'checkUser'
        },
        { slot: 'schedule' }
      ],
      queryParam: {
        pageSize: 10,
        pageNo: 1
      },
      tableData: [],
      total: 1,
      mdl: {}
    }
  },
  methods: {
    edit(row) {
      console.log('table row', row)
      this.mdl = Object.assign({}, row)
      const { planId, planType } = row
      this.handleGetList({ planId, planType })
    },
    async handleGetList(param = {}) {
      this.loading = true
      this.queryParam = Object.assign(this.queryParam, param)
      const res = await planDetails(this.queryParam)
      console.log('res', res)

      if (res && res.data.records.length > 0) {
        const {
          state,
          data: { records, total }
        } = res
        this.tableData = records
        this.total = total
        console.log('total', total)
      } else {
        this.tableData = []
        this.total = 1
      }
      this.loading = false
    }
  }
}
</script>
